{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "\n",
    "from sklearn.metrics import r2_score\n",
    "from sklearn.metrics import mean_squared_error\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>334</th>\n",
       "      <th>335</th>\n",
       "      <th>336</th>\n",
       "      <th>337</th>\n",
       "      <th>338</th>\n",
       "      <th>339</th>\n",
       "      <th>340</th>\n",
       "      <th>341</th>\n",
       "      <th>342</th>\n",
       "      <th>SalePrice</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.227483</td>\n",
       "      <td>-0.202770</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>0.700717</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>1.253123</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>1.053769</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>208500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.670403</td>\n",
       "      <td>-0.086107</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>0.700717</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>-0.694099</td>\n",
       "      <td>1.858393</td>\n",
       "      <td>0.159469</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>181500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.316067</td>\n",
       "      <td>0.081281</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>-1.028509</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>1.253123</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>0.987524</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>223500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.079843</td>\n",
       "      <td>-0.091179</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>-1.028509</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>1.253123</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>-1.860986</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>140000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.788515</td>\n",
       "      <td>0.386636</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>-1.028509</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>1.253123</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>0.954402</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>250000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 344 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          0         1         2         3         4         5         6  \\\n",
       "0  0.227483 -0.202770  0.064327 -0.243378  0.700717  0.026216  0.226042   \n",
       "1  0.670403 -0.086107  0.064327 -0.243378  0.700717  0.026216  0.226042   \n",
       "2  0.316067  0.081281  0.064327 -0.243378 -1.028509  0.026216  0.226042   \n",
       "3  0.079843 -0.091179  0.064327 -0.243378 -1.028509  0.026216  0.226042   \n",
       "4  0.788515  0.386636  0.064327 -0.243378 -1.028509  0.026216  0.226042   \n",
       "\n",
       "          7         8         9    ...      334  335  336  337  338  339  340  \\\n",
       "0  1.253123 -0.419233  1.053769    ...        1    1    1    1    1    1    1   \n",
       "1 -0.694099  1.858393  0.159469    ...        1    1    1    1    1    1    1   \n",
       "2  1.253123 -0.419233  0.987524    ...        1    1    1    1    1    1    1   \n",
       "3  1.253123 -0.419233 -1.860986    ...        1    1    1    1    1    1    1   \n",
       "4  1.253123 -0.419233  0.954402    ...        1    1    1    1    1    1    1   \n",
       "\n",
       "   341  342  SalePrice  \n",
       "0    1    1     208500  \n",
       "1    1    1     181500  \n",
       "2    1    1     223500  \n",
       "3    1    1     140000  \n",
       "4    1    1     250000  \n",
       "\n",
       "[5 rows x 344 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = pd.read_csv('./Ames_House/AmesHouse_FE_train.csv')\n",
    "data2 = pd.read_csv('./Ames_House/AmesHouse_FE_test.csv')\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1456, 344)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>334</th>\n",
       "      <th>335</th>\n",
       "      <th>336</th>\n",
       "      <th>337</th>\n",
       "      <th>338</th>\n",
       "      <th>339</th>\n",
       "      <th>340</th>\n",
       "      <th>341</th>\n",
       "      <th>342</th>\n",
       "      <th>SalePrice</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>1.456000e+03</td>\n",
       "      <td>1.456000e+03</td>\n",
       "      <td>1.456000e+03</td>\n",
       "      <td>1.456000e+03</td>\n",
       "      <td>1.456000e+03</td>\n",
       "      <td>1.456000e+03</td>\n",
       "      <td>1.456000e+03</td>\n",
       "      <td>1.456000e+03</td>\n",
       "      <td>1.456000e+03</td>\n",
       "      <td>1.456000e+03</td>\n",
       "      <td>...</td>\n",
       "      <td>1456.0</td>\n",
       "      <td>1456.0</td>\n",
       "      <td>1456.0</td>\n",
       "      <td>1456.0</td>\n",
       "      <td>1456.0</td>\n",
       "      <td>1456.0</td>\n",
       "      <td>1456.0</td>\n",
       "      <td>1456.0</td>\n",
       "      <td>1456.0</td>\n",
       "      <td>1456.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>4.631460e-14</td>\n",
       "      <td>-3.276988e-14</td>\n",
       "      <td>2.301114e-13</td>\n",
       "      <td>9.269630e-14</td>\n",
       "      <td>-9.271838e-13</td>\n",
       "      <td>6.079630e-14</td>\n",
       "      <td>-7.140564e-14</td>\n",
       "      <td>1.076847e-12</td>\n",
       "      <td>-2.061120e-13</td>\n",
       "      <td>2.256522e-13</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>180151.233516</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>1.000344e+00</td>\n",
       "      <td>1.000344e+00</td>\n",
       "      <td>1.000344e+00</td>\n",
       "      <td>1.000344e+00</td>\n",
       "      <td>1.000344e+00</td>\n",
       "      <td>1.000344e+00</td>\n",
       "      <td>1.000344e+00</td>\n",
       "      <td>1.000344e+00</td>\n",
       "      <td>1.000344e+00</td>\n",
       "      <td>1.000344e+00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>76696.592530</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>-1.691837e+00</td>\n",
       "      <td>-9.281155e-01</td>\n",
       "      <td>-1.554563e+01</td>\n",
       "      <td>-2.433785e-01</td>\n",
       "      <td>-4.486961e+00</td>\n",
       "      <td>-3.814446e+01</td>\n",
       "      <td>-7.007295e+00</td>\n",
       "      <td>-2.641321e+00</td>\n",
       "      <td>-2.696860e+00</td>\n",
       "      <td>-3.285242e+00</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>34900.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>-4.516607e-01</td>\n",
       "      <td>-2.952139e-01</td>\n",
       "      <td>6.432675e-02</td>\n",
       "      <td>-2.433785e-01</td>\n",
       "      <td>-1.028509e+00</td>\n",
       "      <td>2.621613e-02</td>\n",
       "      <td>2.260418e-01</td>\n",
       "      <td>-6.940990e-01</td>\n",
       "      <td>-4.192334e-01</td>\n",
       "      <td>-5.692198e-01</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>129900.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>1.684272e-01</td>\n",
       "      <td>-9.944678e-02</td>\n",
       "      <td>6.432675e-02</td>\n",
       "      <td>-2.433785e-01</td>\n",
       "      <td>7.007165e-01</td>\n",
       "      <td>2.621613e-02</td>\n",
       "      <td>2.260418e-01</td>\n",
       "      <td>-6.940990e-01</td>\n",
       "      <td>-4.192334e-01</td>\n",
       "      <td>2.698005e-02</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>163000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>6.408751e-01</td>\n",
       "      <td>1.155699e-01</td>\n",
       "      <td>6.432675e-02</td>\n",
       "      <td>-2.433785e-01</td>\n",
       "      <td>7.007165e-01</td>\n",
       "      <td>2.621613e-02</td>\n",
       "      <td>2.260418e-01</td>\n",
       "      <td>1.253123e+00</td>\n",
       "      <td>-4.192334e-01</td>\n",
       "      <td>9.544021e-01</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>214000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>7.550426e+00</td>\n",
       "      <td>2.077593e+01</td>\n",
       "      <td>6.432675e-02</td>\n",
       "      <td>5.125698e+00</td>\n",
       "      <td>7.007165e-01</td>\n",
       "      <td>2.621613e-02</td>\n",
       "      <td>2.260418e-01</td>\n",
       "      <td>1.253123e+00</td>\n",
       "      <td>1.858393e+00</td>\n",
       "      <td>1.285624e+00</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>625000.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8 rows × 344 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                  0             1             2             3             4  \\\n",
       "count  1.456000e+03  1.456000e+03  1.456000e+03  1.456000e+03  1.456000e+03   \n",
       "mean   4.631460e-14 -3.276988e-14  2.301114e-13  9.269630e-14 -9.271838e-13   \n",
       "std    1.000344e+00  1.000344e+00  1.000344e+00  1.000344e+00  1.000344e+00   \n",
       "min   -1.691837e+00 -9.281155e-01 -1.554563e+01 -2.433785e-01 -4.486961e+00   \n",
       "25%   -4.516607e-01 -2.952139e-01  6.432675e-02 -2.433785e-01 -1.028509e+00   \n",
       "50%    1.684272e-01 -9.944678e-02  6.432675e-02 -2.433785e-01  7.007165e-01   \n",
       "75%    6.408751e-01  1.155699e-01  6.432675e-02 -2.433785e-01  7.007165e-01   \n",
       "max    7.550426e+00  2.077593e+01  6.432675e-02  5.125698e+00  7.007165e-01   \n",
       "\n",
       "                  5             6             7             8             9  \\\n",
       "count  1.456000e+03  1.456000e+03  1.456000e+03  1.456000e+03  1.456000e+03   \n",
       "mean   6.079630e-14 -7.140564e-14  1.076847e-12 -2.061120e-13  2.256522e-13   \n",
       "std    1.000344e+00  1.000344e+00  1.000344e+00  1.000344e+00  1.000344e+00   \n",
       "min   -3.814446e+01 -7.007295e+00 -2.641321e+00 -2.696860e+00 -3.285242e+00   \n",
       "25%    2.621613e-02  2.260418e-01 -6.940990e-01 -4.192334e-01 -5.692198e-01   \n",
       "50%    2.621613e-02  2.260418e-01 -6.940990e-01 -4.192334e-01  2.698005e-02   \n",
       "75%    2.621613e-02  2.260418e-01  1.253123e+00 -4.192334e-01  9.544021e-01   \n",
       "max    2.621613e-02  2.260418e-01  1.253123e+00  1.858393e+00  1.285624e+00   \n",
       "\n",
       "           ...           334     335     336     337     338     339     340  \\\n",
       "count      ...        1456.0  1456.0  1456.0  1456.0  1456.0  1456.0  1456.0   \n",
       "mean       ...           1.0     1.0     1.0     1.0     1.0     1.0     1.0   \n",
       "std        ...           0.0     0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "min        ...           1.0     1.0     1.0     1.0     1.0     1.0     1.0   \n",
       "25%        ...           1.0     1.0     1.0     1.0     1.0     1.0     1.0   \n",
       "50%        ...           1.0     1.0     1.0     1.0     1.0     1.0     1.0   \n",
       "75%        ...           1.0     1.0     1.0     1.0     1.0     1.0     1.0   \n",
       "max        ...           1.0     1.0     1.0     1.0     1.0     1.0     1.0   \n",
       "\n",
       "          341     342      SalePrice  \n",
       "count  1456.0  1456.0    1456.000000  \n",
       "mean      1.0     1.0  180151.233516  \n",
       "std       0.0     0.0   76696.592530  \n",
       "min       1.0     1.0   34900.000000  \n",
       "25%       1.0     1.0  129900.000000  \n",
       "50%       1.0     1.0  163000.000000  \n",
       "75%       1.0     1.0  214000.000000  \n",
       "max       1.0     1.0  625000.000000  \n",
       "\n",
       "[8 rows x 344 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>333</th>\n",
       "      <th>334</th>\n",
       "      <th>335</th>\n",
       "      <th>336</th>\n",
       "      <th>337</th>\n",
       "      <th>338</th>\n",
       "      <th>339</th>\n",
       "      <th>340</th>\n",
       "      <th>341</th>\n",
       "      <th>342</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.670403</td>\n",
       "      <td>0.119019</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>0.700717</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>-0.694099</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>-0.337364</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.699931</td>\n",
       "      <td>0.387346</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>-1.028509</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>-0.694099</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>-0.436731</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.493235</td>\n",
       "      <td>0.343014</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>-1.028509</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>-0.694099</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>0.855035</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.611347</td>\n",
       "      <td>-0.047760</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>-1.028509</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>-0.694099</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>0.888158</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-0.422133</td>\n",
       "      <td>-0.552255</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>-1.028509</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>1.253123</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>0.689424</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 343 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          0         1         2         3         4         5         6  \\\n",
       "0  0.670403  0.119019  0.064327 -0.243378  0.700717  0.026216  0.226042   \n",
       "1  0.699931  0.387346  0.064327 -0.243378 -1.028509  0.026216  0.226042   \n",
       "2  0.493235  0.343014  0.064327 -0.243378 -1.028509  0.026216  0.226042   \n",
       "3  0.611347 -0.047760  0.064327 -0.243378 -1.028509  0.026216  0.226042   \n",
       "4 -0.422133 -0.552255  0.064327 -0.243378 -1.028509  0.026216  0.226042   \n",
       "\n",
       "          7         8         9 ...   333  334  335  336  337  338  339  340  \\\n",
       "0 -0.694099 -0.419233 -0.337364 ...     1    1    1    1    1    1    1    1   \n",
       "1 -0.694099 -0.419233 -0.436731 ...     1    1    1    1    1    1    1    1   \n",
       "2 -0.694099 -0.419233  0.855035 ...     1    1    1    1    1    1    1    1   \n",
       "3 -0.694099 -0.419233  0.888158 ...     1    1    1    1    1    1    1    1   \n",
       "4  1.253123 -0.419233  0.689424 ...     1    1    1    1    1    1    1    1   \n",
       "\n",
       "   341  342  \n",
       "0    1    1  \n",
       "1    1    1  \n",
       "2    1    1  \n",
       "3    1    1  \n",
       "4    1    1  \n",
       "\n",
       "[5 rows x 343 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y = data['SalePrice'].values# np.log(train.SalePrice)\n",
    "X = data.drop('SalePrice', axis=1)\n",
    "predict_id = data2['Id'].values\n",
    "X2 = data2.drop('Id', axis=1)\n",
    "X2.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sklearn/cross_validation.py:41: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.\n",
      "  \"This module will be removed in 0.20.\", DeprecationWarning)\n"
     ]
    }
   ],
   "source": [
    "from sklearn.cross_validation import train_test_split\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=33, test_size=0.2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>333</th>\n",
       "      <th>334</th>\n",
       "      <th>335</th>\n",
       "      <th>336</th>\n",
       "      <th>337</th>\n",
       "      <th>338</th>\n",
       "      <th>339</th>\n",
       "      <th>340</th>\n",
       "      <th>341</th>\n",
       "      <th>342</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>782</th>\n",
       "      <td>-0.658357</td>\n",
       "      <td>-0.420881</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>2.441160</td>\n",
       "      <td>0.700717</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>-0.694099</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>-1.894108</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>852</th>\n",
       "      <td>1.320019</td>\n",
       "      <td>0.757931</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>0.700717</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>-0.694099</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>-0.536098</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>804</th>\n",
       "      <td>0.522763</td>\n",
       "      <td>-0.070889</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>0.700717</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>-0.694099</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>-0.138631</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>609</th>\n",
       "      <td>-1.691837</td>\n",
       "      <td>0.060991</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>0.700717</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>1.253123</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>0.954402</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>646</th>\n",
       "      <td>0.818043</td>\n",
       "      <td>0.000326</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>-1.028509</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>-0.694099</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>-0.602342</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 343 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            0         1         2         3         4         5         6  \\\n",
       "782 -0.658357 -0.420881  0.064327  2.441160  0.700717  0.026216  0.226042   \n",
       "852  1.320019  0.757931  0.064327 -0.243378  0.700717  0.026216  0.226042   \n",
       "804  0.522763 -0.070889  0.064327 -0.243378  0.700717  0.026216  0.226042   \n",
       "609 -1.691837  0.060991  0.064327 -0.243378  0.700717  0.026216  0.226042   \n",
       "646  0.818043  0.000326  0.064327 -0.243378 -1.028509  0.026216  0.226042   \n",
       "\n",
       "            7         8         9 ...   333  334  335  336  337  338  339  \\\n",
       "782 -0.694099 -0.419233 -1.894108 ...     1    1    1    1    1    1    1   \n",
       "852 -0.694099 -0.419233 -0.536098 ...     1    1    1    1    1    1    1   \n",
       "804 -0.694099 -0.419233 -0.138631 ...     1    1    1    1    1    1    1   \n",
       "609  1.253123 -0.419233  0.954402 ...     1    1    1    1    1    1    1   \n",
       "646 -0.694099 -0.419233 -0.602342 ...     1    1    1    1    1    1    1   \n",
       "\n",
       "     340  341  342  \n",
       "782    1    1    1  \n",
       "852    1    1    1  \n",
       "804    1    1    1  \n",
       "609    1    1    1  \n",
       "646    1    1    1  \n",
       "\n",
       "[5 rows x 343 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_train.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>333</th>\n",
       "      <th>334</th>\n",
       "      <th>335</th>\n",
       "      <th>336</th>\n",
       "      <th>337</th>\n",
       "      <th>338</th>\n",
       "      <th>339</th>\n",
       "      <th>340</th>\n",
       "      <th>341</th>\n",
       "      <th>342</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>981</th>\n",
       "      <td>-1.691837</td>\n",
       "      <td>0.081281</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>0.700717</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>1.253123</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>1.020647</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>746</th>\n",
       "      <td>0.050315</td>\n",
       "      <td>0.014630</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>-1.028509</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>1.253123</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>0.821913</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1145</th>\n",
       "      <td>0.522763</td>\n",
       "      <td>0.157366</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>0.700717</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>1.253123</td>\n",
       "      <td>1.858393</td>\n",
       "      <td>-0.999809</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1296</th>\n",
       "      <td>-1.691837</td>\n",
       "      <td>0.031775</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>-1.028509</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>1.253123</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>0.921280</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1365</th>\n",
       "      <td>-0.274493</td>\n",
       "      <td>0.018891</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>-2.757735</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>1.253123</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>1.053769</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 343 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             0         1         2         3         4         5         6  \\\n",
       "981  -1.691837  0.081281  0.064327 -0.243378  0.700717  0.026216  0.226042   \n",
       "746   0.050315  0.014630  0.064327 -0.243378 -1.028509  0.026216  0.226042   \n",
       "1145  0.522763  0.157366  0.064327 -0.243378  0.700717  0.026216  0.226042   \n",
       "1296 -1.691837  0.031775  0.064327 -0.243378 -1.028509  0.026216  0.226042   \n",
       "1365 -0.274493  0.018891  0.064327 -0.243378 -2.757735  0.026216  0.226042   \n",
       "\n",
       "             7         8         9 ...   333  334  335  336  337  338  339  \\\n",
       "981   1.253123 -0.419233  1.020647 ...     1    1    1    1    1    1    1   \n",
       "746   1.253123 -0.419233  0.821913 ...     1    1    1    1    1    1    1   \n",
       "1145  1.253123  1.858393 -0.999809 ...     1    1    1    1    1    1    1   \n",
       "1296  1.253123 -0.419233  0.921280 ...     1    1    1    1    1    1    1   \n",
       "1365  1.253123 -0.419233  1.053769 ...     1    1    1    1    1    1    1   \n",
       "\n",
       "      340  341  342  \n",
       "981     1    1    1  \n",
       "746     1    1    1  \n",
       "1145    1    1    1  \n",
       "1296    1    1    1  \n",
       "1365    1    1    1  \n",
       "\n",
       "[5 rows x 343 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_test.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# from sklearn.preprocessing import StandardScaler\n",
    "# ss_X = StandardScaler()\n",
    "# ss_y = StandardScaler()\n",
    "# X_train = ss_X.fit_transform(X_train)\n",
    "# X_test = ss_X.transform(X_test)\n",
    "# y_train = ss_y.fit_transform(y_train.reshape(-1, 1))\n",
    "# y_test = ss_y.transform(y_test.reshape(-1,1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/linalg/basic.py:1226: RuntimeWarning: internal gelsd driver lwork query error, required iwork dimension not returned. This is likely the result of LAPACK bug 0038, fixed in LAPACK 3.2.2 (released July 21, 2010). Falling back to 'gelss' driver.\n",
      "  warnings.warn(mesg, RuntimeWarning)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([  1.01281082e+03,   5.44942994e+03,   1.90494285e+03,\n",
       "        -4.52824886e+01,   2.58719304e+02,   1.04804729e+03,\n",
       "         9.24763008e+02,   1.02884456e+11,  -3.60451243e+03,\n",
       "         1.50166614e+04,   2.34483421e+03,   2.01578546e+03,\n",
       "        -2.81089798e+10,  -2.40951330e+03,  -7.59131057e+02,\n",
       "         4.06365805e+02,   5.26595814e+03,   7.83805666e+02,\n",
       "         4.16353845e+14,   6.29016684e+02,   1.56303713e+14,\n",
       "         4.27910134e+14,   6.08359288e+13,   1.24051526e+03,\n",
       "         1.49288569e+14,   1.74440985e+14,   3.16467622e+13,\n",
       "         2.31176184e+14,   8.61129547e+13,   1.97870300e+13,\n",
       "         9.11495208e+13,   4.18176385e+13,  -3.31859028e+03,\n",
       "        -3.38446110e+03,  -4.02571232e+03,   3.29057635e+03,\n",
       "         3.93764582e+03,   7.86865294e+10,  -4.06576418e+02,\n",
       "         3.42610405e+02,  -2.62020571e+10,  -5.89709652e+05,\n",
       "        -1.51824971e+02,   1.24922744e+04,  -4.97245085e+02,\n",
       "         1.81850280e+03,  -2.16105414e+14,  -2.02348669e+14,\n",
       "        -9.70770216e+13,  -1.84611677e+14,  -4.01257747e+02,\n",
       "        -1.52535702e+04,   6.56039085e+03,   2.51231789e+02,\n",
       "         1.13392084e+04,  -1.23189321e+04,   1.56616890e+03,\n",
       "         5.69413392e+03,  -7.86865270e+10,   2.31731005e+04,\n",
       "         1.77191587e+04,  -1.29504151e+14,  -8.48205489e+14,\n",
       "         1.20935237e+14,   3.46746950e+14,  -6.11255136e+09,\n",
       "        -5.42545832e+09,  -4.18417179e+05,   2.11819348e+05,\n",
       "        -1.28190157e+05,   1.40194244e+06,  -4.79944167e+05,\n",
       "         8.61242959e+05,  -1.27267387e+06,   4.31598804e+05,\n",
       "        -8.31233906e+05,   7.73280872e+09,  -3.76424982e+10,\n",
       "        -7.35817185e+10,   1.32789411e+10,  -3.55567836e+09,\n",
       "         2.09746997e+10,   7.91922506e+04,  -3.86444322e+04,\n",
       "         1.13974977e+04,   3.61265316e+05,  -1.15732762e+05,\n",
       "         4.02247701e+05,   1.13165463e+05,  -2.97634818e+04,\n",
       "         9.43501629e+04,  -2.60485011e+10,  -2.11554008e+09,\n",
       "         5.62730202e+10,   4.55766364e+05,  -1.78184938e+05,\n",
       "         2.93902659e+05,   1.99808144e+09,   2.14735565e+10,\n",
       "        -4.51109537e+09,   1.99808424e+09,   1.99808946e+09,\n",
       "        -1.95150963e+10,  -7.03315839e+09,  -7.03315606e+09,\n",
       "         2.32614812e+10,  -1.60215093e+10,  -1.60215114e+10,\n",
       "        -1.60215008e+10,  -1.60215126e+10,  -1.60215101e+10,\n",
       "        -1.60215200e+10,  -1.60215045e+10,  -1.60214982e+10,\n",
       "        -1.60214881e+10,  -4.26197086e+09,  -4.19907361e+08,\n",
       "        -4.19902686e+08,  -4.19894494e+08,  -1.35234968e+09,\n",
       "        -4.19905572e+08,  -9.59632704e+08,  -9.56292182e+09,\n",
       "        -4.19896113e+08,  -5.11066639e+09,  -1.17272857e+10,\n",
       "        -1.17272850e+10,  -1.17272853e+10,  -1.17272783e+10,\n",
       "        -1.17272872e+10,  -1.17272938e+10,  -5.24976396e+09,\n",
       "        -5.24977571e+09,  -5.24978412e+09,  -5.24974970e+09,\n",
       "        -9.81409438e+09,  -5.24978797e+09,  -5.24977236e+09,\n",
       "        -5.24976736e+09,  -5.24976425e+09,  -5.24976832e+09,\n",
       "        -5.24969997e+09,  -5.24974865e+09,  -5.24977298e+09,\n",
       "        -5.24977547e+09,  -5.24975880e+09,  -1.07131990e+10,\n",
       "        -5.61121692e+09,  -5.61122228e+09,  -5.61119447e+09,\n",
       "        -5.61121863e+09,  -1.04689206e+09,  -5.61118136e+09,\n",
       "        -5.61121098e+09,  -5.61120642e+09,  -5.61121156e+09,\n",
       "        -5.61124494e+09,  -5.61121526e+09,  -5.61123695e+09,\n",
       "        -5.61121922e+09,  -5.61120621e+09,  -5.61120283e+09,\n",
       "        -5.61121573e+09,   8.90453954e+09,  -2.50123795e+09,\n",
       "        -2.50123662e+09,  -2.50123468e+09,  -2.50124231e+09,\n",
       "        -2.50123456e+09,   6.52833079e+09,   1.81235589e+10,\n",
       "         1.81235576e+10,   1.81235616e+10,   1.81235543e+10,\n",
       "         1.81235432e+10,   1.81235152e+10,  -1.86975575e+09,\n",
       "        -3.09444671e+10,   2.26303886e+08,  -3.09444693e+10,\n",
       "        -3.09444681e+10,  -7.20249855e+09,   8.32780869e+09,\n",
       "         8.32782712e+09,   8.32783069e+09,   8.32783216e+09,\n",
       "         8.32783966e+09,   8.32782878e+09,   1.31523968e+09,\n",
       "         9.31518758e+09,  -1.49533952e+09,   4.00639559e+09,\n",
       "         4.00638344e+09,   4.00638725e+09,   4.00639119e+09,\n",
       "         4.00640275e+09,  -4.40557850e+08,  -2.67601503e+09,\n",
       "        -2.67598252e+09,  -2.67601139e+09,  -2.67600152e+09,\n",
       "        -2.67599391e+09,  -2.67600591e+09,  -2.67600659e+09,\n",
       "        -2.67599525e+09,  -5.70914738e+09,   2.42767452e+09,\n",
       "         2.42767873e+09,   2.42766602e+09,   2.42767239e+09,\n",
       "        -7.14273513e+09,  -2.61614245e+08,  -2.61608302e+08,\n",
       "        -2.61621481e+08,  -2.61630816e+08,  -2.61617193e+08,\n",
       "        -2.79901456e+09,   4.59338570e+09,  -1.26327204e+08,\n",
       "         4.59337300e+09,   4.59336641e+09,  -1.48820766e+10,\n",
       "         4.59340779e+09,   4.59340140e+09,   4.59341177e+09,\n",
       "         4.59337458e+09,   4.59341919e+09,   4.59341064e+09,\n",
       "         4.59341819e+09,   4.59340642e+09,   4.59338950e+09,\n",
       "         4.59339471e+09,   1.11025662e+10,   5.94993529e+06,\n",
       "        -1.29843739e+09,  -1.29838444e+09,  -1.29840974e+09,\n",
       "        -1.29840244e+09,  -1.29840762e+09,   4.16639215e+08,\n",
       "         1.25417626e+10,   1.25417748e+10,   7.37719292e+07,\n",
       "         1.25417830e+10,   7.72872707e+08,   4.78418941e+08,\n",
       "        -6.11464936e+07,  -6.11520596e+07,  -6.11536481e+07,\n",
       "        -6.12304489e+07,  -8.94571167e-02,   1.41148246e+09,\n",
       "         1.41148025e+09,   1.41148311e+09,   1.41147530e+09,\n",
       "         1.41148192e+09,   1.41148045e+09,   1.41148058e+09,\n",
       "         1.41148109e+09,   1.41148396e+09,   1.41148130e+09,\n",
       "         1.41147842e+09,   1.41148505e+09,   0.00000000e+00,\n",
       "         7.46978703e+08,   7.47009534e+08,   7.47000298e+08,\n",
       "         7.46996040e+08,   7.46984166e+08,   7.46977934e+08,\n",
       "         7.47009687e+08,   7.46976115e+08,   7.46974395e+08,\n",
       "         7.46986017e+08,   7.46972274e+08,   7.46974201e+08,\n",
       "         7.46979508e+08,   7.46997913e+08,   7.46979739e+08,\n",
       "         7.46990066e+08,   7.47012057e+08,   7.46981342e+08,\n",
       "         7.46986031e+08,   7.46984102e+08,   7.46982270e+08,\n",
       "         7.46979439e+08,   7.47027316e+08,   7.46981939e+08,\n",
       "         7.47004777e+08,   0.00000000e+00,  -1.53678634e+09,\n",
       "        -1.53672640e+09,  -1.53676205e+09,  -1.53678177e+09,\n",
       "        -1.53678437e+09,  -1.53678010e+09,  -1.53676504e+09,\n",
       "         0.00000000e+00,   3.90958882e+09,   3.90959537e+09,\n",
       "         3.90960287e+09,   3.90959940e+09,   3.90961398e+09,\n",
       "         3.90963734e+09,   0.00000000e+00,  -4.21288259e+09,\n",
       "        -4.21287401e+09,  -4.21288371e+09,  -4.21288622e+09,\n",
       "        -4.21287525e+09,   1.52958923e+10,   0.00000000e+00,\n",
       "        -6.80831112e+08,  -6.80801066e+08,  -6.80811015e+08,\n",
       "        -6.80812296e+08,  -6.80822636e+08,  -6.80827021e+08,\n",
       "        -6.80806824e+08,  -6.80853388e+08,  -6.80833908e+08,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Linear Regression\n",
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "lr = LinearRegression()\n",
    "lr.fit(X_train, y_train)\n",
    "\n",
    "lr_y_predict = lr.predict(X_test)\n",
    "lr_y_predict_train = lr.predict(X_train)\n",
    "\n",
    "lr.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LinearREgression on train is  0.940369445012\n",
      "LinearRegression on test is  -307389115.61\n",
      "LR_RMSE on train: 18869.8304163\n",
      "LR_RMSE on test: 1301104103.99\n"
     ]
    }
   ],
   "source": [
    "print('LinearREgression on train is ', lr.score(X_train, y_train))\n",
    "print('LinearRegression on test is ', lr.score(X_test, y_test))\n",
    "lr_RMSE_train = np.sqrt(mean_squared_error(lr_y_predict_train, y_train))\n",
    "lr_RMSE_test = np.sqrt(mean_squared_error(lr_y_predict, y_test))\n",
    "print('LR_RMSE on train:', lr_RMSE_train)\n",
    "print('LR_RMSE on test:', lr_RMSE_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},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47LDDmDx5Mvvttx//9m//1qvXdM8993DMMccA0NbWxplnnsn06dPZbbfd1gv1G264gUMOOYTJkydz7rnnrgvk8847j9bWVvbdd991bQC1239/7nOf46CDDuKWW27pVV16ozfD5u8HTgUeiogFVdlFwNeAmyPiLGAJcHy17qfUPia2mNpHxT7WtNpKkgbVmjVrmDNnDmeddRYAd955J0888QQPPPAAmcmxxx7L3Llz6ejoYOedd+YnP/kJAC+++OJ6x1m2bBmXXHIJ8+fPZ/vtt+cDH/gAU6ZM2eC5R4wYwW233cZ2223Hc889x9SpUzn22GPXm/z1wx/+kCOOOIKLL76YNWvW8Oqrr/bpdT722GPcfffdvPzyy7z3ve/lvPPOY/HixcyePZt7772XlpYWzj//fG688UZOO+00vvrVrzJ69GjWrFnDjBkzWLhwIQcccAAAO+64Iw8+2NxPTG80vDPzF0BP0+JmdLN9Ap9osF6SpM3Ia6+9xuTJk2lvb2fvvffmgx/8IFAL7zvvvHNd8K5atYonnniCQw89lM985jN87nOf45hjjuHQQw9d73j3338/06dPZ8yY2hdonXDCCfz617/eYB0yk4suuoi5c+ey1VZb0d7ezvLly3nnO9+5bpuDDz6YM888kzfffJPjjjuOyZMn9+n1Hn300QwfPpzhw4czduxYli9fzpw5c5g/fz4HH3zwujYZO3YsADfffDOzZs1i9erVLFu2jEceeWRdeJ9wwgl9qsOGeHtUSdJGdV7zXrJkCZm57pp3ZnLhhReyYMECFixYwOLFiznrrLPYc889efDBB9l///35whe+wJe+9KVen2vrrbdm7dq1AKxdu5bf/e53ANx44410dHQwf/58FixYwLhx497yWenDDjuMuXPnsssuu3DGGWdw/fXX9+n1Dh8+fN3ysGHDWL16NZnJ6aefvu61Pv7447S1tfH0009z2WWXMWfOHBYuXMjRRx+9Xr222WabPtVhQ7w9qqRNsikznZs9K1qD7x3veAeXX345xx13HOeffz5HHHEEX/ziFzn55JMZOXIk7e3ttLS0sHr1akaPHs0pp5zCqFGjuPrqq9c7zvve9z4++clPsnLlSrbbbjtuueUWDjzwQK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FXqyGa38OHB4RO1SXiQ4Hfl6teykiplZzMk6rO9ZQMRBt2dM5Bt9gz5jbEh7UgmQp8AawnNobonPdxdRm6D5O3WxQajMif12tu7iufDdqwbMYuAUYXpWPqJ4vrtbvtrFzbGkP4AfAQ8BCav+oxg9kO/vouT19vKWddqM2G/8/gYc724ra/Ik5wBPAPwOjq/IArqza9SHW/9TKmdX7cTHwsbryVmp/EDwJXEF1x8wt8QHcBCwD3qz+rz1rINqyp3NsDg9vjypJUmEcNpcpz9szAAAAKUlEQVQkqTCGtyRJhTG8JUkqjOEtSVJhDG9JkgpjeEuSVBjDW5Kkwvx/p2QILLwTZAwAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x117d63c88>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "f, ax = plt.subplots(figsize=(7, 5)) \n",
    "f.tight_layout() \n",
    "ax.hist(y_train - lr_y_predict_train,bins=40, label='Residuals Linear', color='b', alpha=.5); \n",
    "ax.set_title(\"Histogram of Residuals\") \n",
    "ax.legend(loc='best');"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARgAAADQCAYAAADcQn7hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAHm1JREFUeJztnXuUVNW95z9fmlZbjTREFhdbCcQ4uDRGMH0Vh7tyIxlBTaJcl/Fxzeg4RmeiSXxkEWGu62KSmyuRRCOTOyZOTKITjBA1Hd/EqEnWcga0SYNEkYhvOiokgA/gyus3f5xdTXVx6tSp7jpV1VW/z1q16px9HnsfTtePvffvt39fmRmO4zhZMKzWDXAcp3FxA+M4Tma4gXEcJzPcwDiOkxluYBzHyQw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H1GUj2Yh8CxwmKTNecfPlfSjsD1G0r2SuiU9FSJOC+/3BUm/lPS7kI/k2iL1jJW0TlJ7OH5RyIOyUtJP0tbnVA4fIjlZcSRwgZl1563XiWMBcIOZLQ2rvx8APhpz3vGhfDvwtKLEUu/l1wMQ8iMh6VjgGuA/mtlGSaPKrM+pAG5gnKx4MfejL8F/AibmDAMwUlKbmW0rOG+JmW0CkNRFtCTikYR6phElk9oIkPsuoz6nAriBcbJiS972bqJ1MTn2y9sW6SaECycLc/tbCk8sQdr6nArgczBO5oSJ102SjpA0DPiHvMO/AS7P7UiaVOQ20xXlo90fOAN4skS1jwPn5IZGeUOktPU5FcANjFMtriFKE/B/6Z817XJgapiMfQ64pMj1TxOlCFgJ/NzMViRVZmYrifLI/l7SCmB+mfU5FcDd1E7dI+kLwEfN7Mpat8UpD+/BOI6TGd6DcRwnM7wH4zhOZriBcRwnM9zAOI6TGW5gHMfJDDcwjuNkxv8H+K3JjAFBYz8AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1183d0a90>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(4, 3))\n",
    "plt.scatter(y_train, lr_y_predict_train)\n",
    "plt.plot([-3, 3], [-3, 3], '--k')   #数据已经标准化，3倍标准差即可\n",
    "plt.axis('tight')\n",
    "plt.xlabel('True price')\n",
    "plt.ylabel('Predicted price')\n",
    "plt.tight_layout()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([  1.08887649e+03,   5.76492173e+03,   1.83330024e+03,\n",
       "        -1.05514464e+02,   4.62598771e+02,   8.67311120e+02,\n",
       "         1.22030537e+03,  -1.18075733e+03,  -2.71491088e+03,\n",
       "         1.55139041e+04,   2.32277708e+03,   2.57242935e+03,\n",
       "        -5.82958469e+02,  -3.49350101e+03,  -8.42108758e+02,\n",
       "         2.78961226e+02,   5.60959205e+03,   1.18700707e+03,\n",
       "         3.36880633e+02,   1.34589324e+03,  -2.30690290e+03,\n",
       "        -6.47142824e+03,  -7.49551458e+03,   1.35716712e+03,\n",
       "         6.81341400e+03,  -7.86206551e+03,  -1.03529805e+03,\n",
       "        -1.86562742e+03,  -6.14894586e+02,  -1.42159157e+02,\n",
       "         8.80875167e+00,   2.32964497e+03,  -2.96242584e+03,\n",
       "        -4.15787642e+03,  -5.97718320e+03,   2.81103319e+03,\n",
       "         4.23163537e+03,   1.72309401e+03,  -9.37684152e+02,\n",
       "         3.12715073e+02,  -2.54075723e+03,  -1.33516775e+04,\n",
       "         4.85736661e+03,   1.28088062e+04,  -4.69752967e+02,\n",
       "         1.52432011e+03,   1.35121139e+03,  -5.21629063e+02,\n",
       "         7.43911177e+02,   1.98704035e+03,  -1.79921312e+03,\n",
       "        -1.92429283e+04,  -4.35881543e+02,   5.09158033e+02,\n",
       "         1.08117715e+04,  -1.43443650e+04,   3.81280837e+03,\n",
       "         7.19931776e+03,   1.72309401e+03,   2.12169660e+04,\n",
       "         2.23029643e+04,   3.27864916e+02,  -5.28084110e+03,\n",
       "        -1.78097038e+03,   1.80391113e+03,   4.80618164e+02,\n",
       "        -1.90568905e+03,   8.82716511e+02,   2.90255559e+04,\n",
       "         8.73375761e+03,  -3.86174525e+03,   6.61301016e+03,\n",
       "         5.28791309e+03,  -7.18754147e+03,   7.01126064e+03,\n",
       "         7.92338628e+03,  -6.97036036e+02,  -4.00855252e+02,\n",
       "        -1.51916043e+03,   1.01729747e+04,   4.55127852e+02,\n",
       "        -3.63582142e+03,   7.71392018e+03,  -4.73670849e+03,\n",
       "         5.92964198e+02,   9.52243535e+03,  -2.83616734e+03,\n",
       "        -1.55615034e+04,   4.60299143e+03,   1.16329930e+03,\n",
       "        -2.89302296e+03,  -5.82958469e+02,  -5.82958469e+02,\n",
       "        -5.82958469e+02,   1.32988012e+04,  -1.98298178e+04,\n",
       "        -4.37555039e+03,   1.15863134e+04,   3.16957051e+02,\n",
       "        -9.92017040e+02,  -4.23384889e+03,  -6.26389904e+02,\n",
       "         0.00000000e+00,   1.50075906e+03,   4.55025552e+03,\n",
       "         0.00000000e+00,  -2.94729283e+02,  -3.81901879e+03,\n",
       "         5.81688373e+03,  -2.48498841e+03,  -2.82974963e+03,\n",
       "        -1.18667825e+04,   1.94236224e+03,   5.32661713e+03,\n",
       "         1.42604201e+04,   0.00000000e+00,   1.73353021e+03,\n",
       "         3.02003669e+03,   6.91853475e+03,   0.00000000e+00,\n",
       "        -2.48166012e+03,  -4.39934110e+03,   0.00000000e+00,\n",
       "         1.25991415e+03,   0.00000000e+00,   1.47406459e+03,\n",
       "         1.48691471e+02,   1.32718049e+03,   4.33740695e+03,\n",
       "        -8.24291519e+02,  -4.12037404e+02,  -1.38775578e+02,\n",
       "        -2.19048415e+03,  -5.71145932e+03,   1.35865487e+04,\n",
       "        -1.78021229e+03,  -4.07218686e+03,  -2.25185646e+03,\n",
       "         4.71122903e+02,   2.80705703e+03,   7.60861545e+02,\n",
       "         5.28805611e+03,   1.18191273e+04,  -7.48926295e+03,\n",
       "        -1.07865936e+04,   5.73907216e+03,   0.00000000e+00,\n",
       "        -3.00056682e+03,  -2.59827866e+03,   2.70872705e+03,\n",
       "        -5.18945812e+03,  -1.78021229e+03,   1.51285245e+04,\n",
       "        -1.65509573e+03,   5.98512904e+03,  -6.47922426e+02,\n",
       "        -6.45321370e+03,  -4.61629014e+03,  -6.42369085e+03,\n",
       "        -2.96604038e+03,   7.33835039e+03,   1.02871567e+04,\n",
       "        -6.61040277e+01,   0.00000000e+00,   2.78328142e+03,\n",
       "         2.65108609e+02,   3.64583734e+03,  -4.45825515e+03,\n",
       "         3.81504236e+03,   0.00000000e+00,   7.57991851e+03,\n",
       "         4.30332400e+03,   7.60804798e+03,   6.55826671e+03,\n",
       "        -3.44000539e+03,  -1.65585372e+04,   0.00000000e+00,\n",
       "         5.39861576e+03,  -4.78719082e+03,   1.63879100e+03,\n",
       "         3.80079864e+03,   0.00000000e+00,  -1.82196972e+04,\n",
       "         4.22460920e+03,   2.08698246e+03,   9.01597663e+03,\n",
       "         9.15549022e+03,   4.57484403e+03,  -4.78719082e+03,\n",
       "         0.00000000e+00,   0.00000000e+00,   6.08379938e+03,\n",
       "        -4.77566644e+03,   1.40062836e+03,  -1.17793311e+03,\n",
       "         4.52018638e+03,   0.00000000e+00,  -4.54990010e+03,\n",
       "         1.95077476e+03,  -3.50829546e+03,  -1.18016090e+04,\n",
       "         1.45330397e+04,   8.01657570e+03,  -2.49243000e+03,\n",
       "         3.90285895e+03,   0.00000000e+00,   3.22404805e+03,\n",
       "         8.44157516e+03,  -7.54182417e+03,   1.92721553e+03,\n",
       "         0.00000000e+00,   3.52493201e+03,   1.07504813e+04,\n",
       "        -3.17094297e+03,  -6.88271704e+03,   1.82926130e+03,\n",
       "         0.00000000e+00,   1.56723853e+03,   0.00000000e+00,\n",
       "        -1.24423826e+04,  -6.28878504e+03,   3.16957051e+02,\n",
       "         4.07180645e+03,  -1.75521082e+03,   9.56561325e+03,\n",
       "        -3.32874407e+03,   1.16622950e+04,   2.09652033e+03,\n",
       "         6.96428123e+03,   1.81569006e+03,  -3.35231629e+03,\n",
       "        -3.84993152e+03,  -9.92017040e+02,   0.00000000e+00,\n",
       "        -2.34577891e+04,   1.91297570e+04,   3.81586322e+03,\n",
       "         5.89737991e+03,   6.65803586e+02,   0.00000000e+00,\n",
       "        -8.93059820e+03,   1.19304107e+03,   3.38417595e+03,\n",
       "         1.04043958e+04,   0.00000000e+00,  -4.39934110e+03,\n",
       "         7.20044625e+03,   6.08296337e+03,   7.95240558e+03,\n",
       "        -1.07854595e+04,   0.00000000e+00,   2.61283666e+03,\n",
       "        -1.10355514e+03,   1.23254373e+03,  -4.20103961e+03,\n",
       "         2.65382540e+03,   1.08865888e+03,  -2.89770294e+02,\n",
       "        -1.21885122e+03,   4.10126954e+03,  -1.16656173e+02,\n",
       "        -2.46716300e+03,   3.75891581e+03,   0.00000000e+00,\n",
       "        -8.91369202e+03,   8.12705828e+03,   5.32570655e+03,\n",
       "         7.51001137e+03,  -5.20225556e+03,  -9.55039115e+03,\n",
       "         2.21204553e+04,  -1.12985454e+04,  -1.13531388e+04,\n",
       "        -2.63068649e+02,  -1.98809290e+04,  -1.53990950e+04,\n",
       "        -8.70636593e+03,   1.19636351e+04,  -1.08565417e+04,\n",
       "         2.70866183e+03,   2.73798135e+04,  -4.30553492e+03,\n",
       "        -1.18675365e+03,  -5.35916659e+03,  -5.97703934e+03,\n",
       "        -4.94920244e+03,   3.68385951e+04,  -5.32053627e+03,\n",
       "         1.25993340e+04,   0.00000000e+00,  -1.37222947e+04,\n",
       "         1.32545133e+04,   1.62164100e+03,  -2.67105161e+03,\n",
       "        -1.50106762e+04,   3.41550128e+03,   1.91633815e+04,\n",
       "         0.00000000e+00,  -3.64186452e+03,  -3.63104980e+03,\n",
       "         4.12753309e+03,   2.58163644e+03,   9.85717884e+02,\n",
       "         5.62904148e+03,   0.00000000e+00,  -6.15539359e+02,\n",
       "         6.86393345e+03,  -3.79334615e+03,  -3.22666340e+03,\n",
       "         6.84143083e+03,  -1.88008086e+01,   0.00000000e+00,\n",
       "        -1.04750030e+04,   1.63013977e+04,   6.13116421e+03,\n",
       "         8.89171699e+03,   1.82487828e+03,  -4.23758308e+03,\n",
       "         1.34111569e+04,  -1.30380926e+04,  -1.27586209e+04,\n",
       "         0.00000000e+00,   6.05101458e+03,   6.05101458e+03,\n",
       "         6.05101458e+03,   6.05101458e+03,   6.05101458e+03,\n",
       "         6.05101458e+03,   6.05101458e+03,   6.05101458e+03,\n",
       "         6.05101458e+03,   6.05101458e+03,   6.05101458e+03,\n",
       "         6.05101458e+03,   6.05101458e+03,   6.05101458e+03,\n",
       "         6.05101458e+03,   6.05101458e+03,   6.05101458e+03,\n",
       "         6.05101458e+03,   6.05101458e+03,   6.05101458e+03,\n",
       "         6.05101458e+03])"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.linear_model import SGDRegressor\n",
    "\n",
    "sgdr = SGDRegressor(max_iter=1000)\n",
    "\n",
    "sgdr.fit(X_train, y_train)\n",
    "\n",
    "sgdr_y_predict_train = sgdr.predict(X_train)\n",
    "sgdr_y_predict_test = sgdr.predict(X_test)\n",
    "\n",
    "sgdr.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SGDRegressor on train is  0.934500774487\n",
      "SGDRegressor on test is  0.900640960572\n",
      "SGDR_RMSE on train: 19776.6011036\n",
      "SGDR_RMSE on test: 23392.2229983\n"
     ]
    }
   ],
   "source": [
    "print('SGDRegressor on train is ', sgdr.score(X_train, y_train))\n",
    "print('SGDRegressor on test is ', sgdr.score(X_test, y_test))\n",
    "SGDR_RMSE_train = np.sqrt(mean_squared_error(sgdr_y_predict_train, y_train))\n",
    "SGDR_RMSE_test = np.sqrt(mean_squared_error(sgdr_y_predict_test, y_test))\n",
    "print('SGDR_RMSE on train:', SGDR_RMSE_train)\n",
    "print('SGDR_RMSE on test:', SGDR_RMSE_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "#L2\n",
    "\n",
    "from sklearn.linear_model import RidgeCV\n",
    "# alphas = [0.01, 0.1, 1, 10, 20, 40, 80, 100]\n",
    "# alphas = [0.0001,0.001,0.01,0.1,1,10,20,40,80,100,200,400,800,1000]\n",
    "alphas = []\n",
    "for i in range(10000):\n",
    "    alphas.append(10+i*0.0007)\n",
    "reg = RidgeCV(alphas=alphas, store_cv_values=True)\n",
    "reg.fit(X_train, y_train)\n",
    "\n",
    "RidgeCV_y_predict_train = reg.predict(X_train)\n",
    "RidgeCV_y_predict_test = reg.predict(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KG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6P9WJIV+7ZIrSwGvpqX5GnAmu6TyEuqqiaB25IcudRjqz0GvlaV7pPGb0uypTsH+gnd8l2SnJHkxiSbknwsyUu7h70c+K9pfZzZnWzuuiR/Ocs4dyX5+67NJ5OMTVv9siRfSPLVJM/p2q9P8ukkV3Vfz57W/j+7GqReGfhabV4CHAIcDDwfeFt3muiXAOsZfNr0ZOCIaY85Etg87f6fV9U48Azg17pzscy0JzBRVU8DPsXgE55T1lbV4cDrpy3fCrygqg4DTgDeMa39BPCchW+qtDDL/tQK0gIdBZxbVduA7yX5FIMLgRwFfLCq7gduT3LptMfsB0xOu/973WmD13brDgKunTHO/cB/dLffy+B8LVOmbm9m8EcGBh/3/6ckhwDbgCdPa78V+OUFbqe0YAa+BD8F9gBIcgBwKvDMqvpBknOm1s1j+jlKftZ938YDv2N/AnyPwX8euwD/N639Hl0NUq88pKPV5tPACUnWdMfVjwa+AHwW+N3uWP6jGZxwa8oNwBO72w8H7gZ+1LU7bpZxdgGmXgP4feAz89T1COC27j+MkxmcsGvKk1nFZ6zU8uEevlabCxkcn/8Sg73uN1TV7Uk+BDyPwamhvw1cBfyoe8xHGfwB+ERVfSnJ1cCNXbvPzjLO3cDhSd7E4JDMCfPUdQbwoSSvBC7qHj/luV0NUq88W6aakWSvqrorySMZ7PUf2f0xeBhwaXd/25B93VVVey1SXZczuDjHD+ZtLO0E9/DVko8k2QfYDXhrVd0OUFU/TXI6g2uafmspC+oOO73dsNdScA9fkhrhi7aS1AgDX5IaYeBLUiMMfElqhIEvSY34f7itts6aJChYAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x11722a940>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 15.7148\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([  1.58602889e+03,   5.20376696e+03,   1.52358109e+03,\n",
       "        -3.72449520e+02,  -8.67089935e+01,   6.28500674e+02,\n",
       "         1.51260308e+03,   1.52817611e+00,   1.58274852e+03,\n",
       "         1.27140643e+04,   2.07182645e+03,   3.79881720e+03,\n",
       "        -2.64215562e+02,  -3.52660776e+03,  -3.19630870e+02,\n",
       "         1.65395572e+02,   5.39602482e+03,   8.11550816e+02,\n",
       "         4.02824066e+03,   9.48862626e+02,  -1.15354231e+03,\n",
       "        -3.38864629e+03,   1.17426878e+02,   1.12467499e+03,\n",
       "         3.55709005e+03,  -2.77699806e+03,  -5.38369446e+02,\n",
       "         1.79325873e+02,  -7.87533419e+02,  -6.06586507e+02,\n",
       "        -1.00482119e+02,   2.37640288e+03,  -4.21982656e+03,\n",
       "        -3.31716260e+03,  -2.04881919e+02,   3.28826394e+03,\n",
       "         4.34236886e+03,   1.64552138e+03,  -1.41752298e+02,\n",
       "        -3.33679631e+02,  -1.50813536e+03,  -3.29274035e+03,\n",
       "         4.60186640e+03,   1.58711496e+03,  -2.79533825e+02,\n",
       "         1.74252589e+03,   1.23285532e+03,  -6.53335764e+02,\n",
       "         7.12022778e+02,   1.94444686e+03,  -7.86633024e+02,\n",
       "        -7.04262396e+03,  -1.55478680e+03,   8.04939771e+02,\n",
       "         5.30071673e+03,  -3.09280563e+03,   4.07902006e+03,\n",
       "         1.83815555e+03,   1.64552138e+03,   5.47338934e+03,\n",
       "         8.23317488e+03,   8.02853382e+01,   1.80783931e+02,\n",
       "         2.34297865e+02,   1.62168328e+03,  -5.18712176e+02,\n",
       "         2.42455690e+03,   4.41773661e+03,   1.21816754e+04,\n",
       "         1.03237724e+03,   1.01276305e+03,   5.53479099e+03,\n",
       "         1.73694893e+03,   1.85133133e+02,   5.31394392e+03,\n",
       "         2.31690095e+03,   7.35739151e+02,   1.17693500e+03,\n",
       "        -5.22632811e+02,   3.99035631e+03,   4.48777449e+03,\n",
       "        -2.27437725e+03,   4.11102116e+03,   6.27977838e+02,\n",
       "        -1.86528625e+03,   3.26891594e+03,   3.94909038e+02,\n",
       "        -4.76635890e+03,   2.23239163e+03,   2.02121875e+03,\n",
       "        -1.34202379e+03,  -2.64215562e+02,  -2.64215562e+02,\n",
       "        -2.64215562e+02,   1.47966431e+03,  -7.76644182e+03,\n",
       "         3.02763627e+03,   7.60229443e+03,  -9.35643398e+02,\n",
       "        -1.13975761e+03,  -4.32719727e+03,  -1.19969615e+03,\n",
       "         0.00000000e+00,  -1.45713214e+03,   1.45713214e+03,\n",
       "         0.00000000e+00,   1.21740589e+02,  -3.31889739e+03,\n",
       "         5.97368684e+03,  -1.06623448e+03,  -1.15095745e+03,\n",
       "        -4.08502275e+03,   2.86141090e+01,   8.04751998e+02,\n",
       "         2.69231854e+03,   0.00000000e+00,  -2.61562049e+02,\n",
       "         6.00683717e+02,   1.18670254e+03,   0.00000000e+00,\n",
       "        -6.37841850e+02,  -8.19453597e+02,   0.00000000e+00,\n",
       "        -6.85287579e+01,   0.00000000e+00,   8.33483861e+02,\n",
       "         5.79667797e+02,   5.64932720e+01,   8.13638389e+02,\n",
       "        -2.36772215e+03,   8.44388299e+01,  -8.59620279e+02,\n",
       "        -3.44710918e+02,  -1.33102389e+03,   7.18333943e+03,\n",
       "        -5.04340660e+02,   1.85202820e+03,  -2.20263967e+03,\n",
       "         2.42984019e+02,   7.57987863e+02,  -8.61292952e+02,\n",
       "         3.54436196e+02,   2.80993234e+03,  -2.78399790e+03,\n",
       "        -6.37772753e+03,   2.06464573e+03,   0.00000000e+00,\n",
       "        -1.66583802e+03,  -4.28430190e+02,   4.57118265e+02,\n",
       "        -1.05070408e+03,  -5.04340660e+02,   4.16411178e+03,\n",
       "        -2.32529216e+03,   1.29597158e+03,  -2.93538637e+02,\n",
       "        -8.37955551e+02,  -3.94121359e+03,  -6.92808081e+02,\n",
       "        -6.59318928e+02,   3.08644789e+02,   4.75942892e+03,\n",
       "         1.41416455e+03,   0.00000000e+00,   1.01353999e+02,\n",
       "        -6.63896288e+02,   1.97121458e+03,  -2.82148767e+03,\n",
       "         1.41281538e+03,   0.00000000e+00,   2.27871681e+03,\n",
       "        -1.83484287e+03,   3.04840389e+03,   1.59655771e+03,\n",
       "        -1.15494532e+03,  -3.93389023e+03,   0.00000000e+00,\n",
       "         1.93876145e+03,  -1.19391423e+03,  -1.81803221e+03,\n",
       "         1.07318499e+03,   0.00000000e+00,  -5.59649769e+03,\n",
       "         3.31656822e+02,  -1.47270299e+03,   5.07544102e+03,\n",
       "         1.28444115e+03,   1.57157593e+03,  -1.19391423e+03,\n",
       "         0.00000000e+00,   0.00000000e+00,   3.85536525e+03,\n",
       "        -3.86525614e+03,  -8.60061354e+01,  -8.72942417e+02,\n",
       "         9.68839444e+02,   0.00000000e+00,   2.22110101e+02,\n",
       "         1.74339349e+02,  -1.78817658e+03,  -3.01373910e+03,\n",
       "         2.64771885e+03,   4.22377573e+03,  -3.66577238e+03,\n",
       "         1.19974404e+03,   0.00000000e+00,   5.28121791e+02,\n",
       "         6.20848572e+03,  -5.38192556e+03,  -1.35468195e+03,\n",
       "         0.00000000e+00,  -3.43482518e+02,   6.49318092e+03,\n",
       "        -3.54221592e+03,  -1.44063754e+03,  -1.16684494e+03,\n",
       "         0.00000000e+00,   8.73284198e+02,   0.00000000e+00,\n",
       "        -5.69864546e+03,  -2.99154656e+03,  -9.35643398e+02,\n",
       "         1.94403596e+03,  -3.45635085e+03,   2.04084489e+03,\n",
       "        -2.44017600e+02,   3.91888360e+03,   2.71645032e+03,\n",
       "         4.98409072e+03,  -3.15983691e+02,  -1.33187566e+01,\n",
       "        -1.68232575e+03,  -1.13975761e+03,   0.00000000e+00,\n",
       "        -7.06098664e+03,   6.35708498e+03,   6.24591252e+02,\n",
       "         2.62203589e+03,  -2.54272549e+03,   0.00000000e+00,\n",
       "        -4.80234012e+03,  -2.40100709e+03,   2.54303348e+02,\n",
       "         6.94904387e+03,   0.00000000e+00,  -8.19453597e+02,\n",
       "         6.23183491e+02,   1.15370981e+03,   1.81989743e+03,\n",
       "        -2.77733713e+03,   0.00000000e+00,   9.90510865e+02,\n",
       "        -6.47899099e+02,   8.30452936e+02,  -3.74079039e+03,\n",
       "         1.90308147e+03,   1.28793591e+03,  -7.08974276e+02,\n",
       "        -1.63911526e+03,   3.09544153e+03,  -6.26949792e+02,\n",
       "        -2.28972981e+03,   1.54603592e+03,   0.00000000e+00,\n",
       "        -4.46563163e+03,   1.45612127e+03,   2.30342297e+03,\n",
       "         5.99016984e+03,  -2.75379439e+03,  -6.80989146e+03,\n",
       "         1.43921588e+04,  -5.86370408e+03,  -7.33759701e+03,\n",
       "        -1.04986705e+03,  -8.82962762e+03,  -8.61535603e+03,\n",
       "        -4.88676913e+03,   3.07881211e+03,  -6.37577536e+03,\n",
       "        -2.90773353e+02,   1.85875747e+04,  -2.22092173e+03,\n",
       "        -6.34908368e+02,  -1.43046989e+03,  -4.19851209e+03,\n",
       "         3.98054912e+02,   1.76624834e+04,  -3.25828717e+03,\n",
       "         5.15308833e+03,   0.00000000e+00,  -4.34497693e+03,\n",
       "         2.55569421e+03,   5.21934518e+02,  -4.54532586e+02,\n",
       "        -3.85381748e+03,   3.35950228e+02,   5.23974804e+03,\n",
       "         0.00000000e+00,  -1.33805761e+03,  -3.47041218e+03,\n",
       "         1.87731952e+03,   2.56757492e+03,  -6.40718007e+02,\n",
       "         1.00429336e+03,   0.00000000e+00,  -3.39596273e+03,\n",
       "         1.12625639e+03,  -6.83164981e+02,  -2.49095661e+03,\n",
       "         4.76955048e+03,   6.74277449e+02,   0.00000000e+00,\n",
       "        -3.67925166e+03,   4.19677793e+03,   1.33238218e+03,\n",
       "         8.43358454e+02,   1.38085568e+03,   2.89940348e+02,\n",
       "         4.61586756e+03,  -2.02526507e+03,  -6.95466542e+03,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00])"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mse_mean = np.mean(reg.cv_values_, axis = 0)\n",
    "plt.plot(np.log10(alphas), mse_mean.reshape(len(alphas),1))\n",
    "plt.plot(np.log10(reg.alpha_)*np.ones(3), [0.28, 0.29, 0.30])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()\n",
    "\n",
    "print('alpha is:', reg.alpha_)\n",
    "reg.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "RidgeRegression on train is  0.926298160517\n",
      "RidgeRegression on test is 0.909415562833\n",
      "RidgeCV_RMSE on train: 20978.4180262\n",
      "RidgeCV_RMSE on test: 22335.4444283\n"
     ]
    }
   ],
   "source": [
    "print('RidgeRegression on train is ', reg.score(X_train, y_train))\n",
    "print('RidgeRegression on test is', reg.score(X_test, y_test))\n",
    "RidgeCV_RMSE_train = np.sqrt(mean_squared_error(RidgeCV_y_predict_train, y_train))\n",
    "RidgeCV_RMSE_test = np.sqrt(mean_squared_error(RidgeCV_y_predict_test, y_test))\n",
    "print('RidgeCV_RMSE on train:', RidgeCV_RMSE_train)\n",
    "print('RidgeCV_RMSE on test:', RidgeCV_RMSE_test) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sklearn/linear_model/coordinate_descent.py:491: ConvergenceWarning: Objective did not converge. You might want to increase the number of iterations. Fitting data with very small alpha may cause precision problems.\n",
      "  ConvergenceWarning)\n"
     ]
    }
   ],
   "source": [
    "#Lasso\n",
    "\n",
    "from sklearn.linear_model import LassoCV\n",
    "# alphas = [0.01, 0.1, 1, 10, 100] # 100\n",
    "# alphas = [90,100,110,120,130,140] #130\n",
    "alphas = []\n",
    "for i in range(10000):\n",
    "    alphas.append(125+i*0.001)\n",
    "lasso = LassoCV(alphas=alphas)\n",
    "lasso.fit(X_train, y_train)\n",
    "\n",
    "LassoCV_y_predict_train = lasso.predict(X_train)\n",
    "LassoCV_y_predict_test = lasso.predict(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZgAAAERCAYAAABGhLFFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3Xl4VdW5x/HvmwECCSRAAoRBAiIgIAkYEJyVS8WhqKjFoaIoWryVarWD2t5avbXV2jqgVkUUqKUq4lBHlAoVRzBAQIaACApBhjAGAgSSvPePs8NNU4YAOTknye/zPOfh7LXX2ufd59HzZu2191rm7oiIiFS3mEgHICIidZMSjIiIhIUSjIiIhIUSjIiIhIUSjIiIhIUSjIiIhEW9TzBm9pyZbTCzhVWoe4yZzTCzeWa2wMzOq4kYRURqo3qfYIAJwOAq1v01MNndewOXA38JV1AiIrVdvU8w7j4T2FyxzMyONbOpZjbHzD4ys27l1YGmwftk4LsaDFVEpFaJi3QAUWosMMrdvzKzkwj1VM4Gfgu8b2ajgUTgvyIXoohIdFOCqcTMkoCTgZfNrLy4YfDvFcAEd/+zmQ0Anjeznu5eFoFQRUSimhLMf4oBtrp71n72XU8wXuPun5lZApAKbKjB+EREaoV6PwZTmbsXAivN7DIAC8kMdq8CBgblxwMJQEFEAhURiXJW32dTNrMXgDMJ9UTWA3cD04EngXQgHnjR3e81s+7AM0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uIDQ/3O/CddviKaKERGRsNAlMhERCQslGBERCQslGBERCQslGBERCQslGBERCQslGJEjYGY7Dl3roO2nmFmnQ9T5l5llH22dSvXTzGxqVeuLHA0lGJEaZmY9gFh3X1HTn+3uBcBaMzulpj9b6h8lGJGjYCEPmtlCM/vSzIYF5TFm9hczy7PQGibvmFn5E9JXUeEJaTN70sxyKq/NUelzdgQTgS4ysw/MLK3C7suC9T2WmdlpQf0MM/vIzOYGr5Mr1H89iEEkrJRgRI7OUEKTGWYC/wU8GEwRMhTIALoDVwMDKrQ5BZhTYftX7p5N6AnrM8ys134+JxHIcfcewIfA3RX2xbl7P+DWCuUbgEHu3gcYBoypUD8HOO3wT1Xk8MQduoqIHMSpwAvuXkpoUsYPCc0KfSrwsocmOlxnZjMqtEkHCips/8DMbiT0/2M6oaS0oNLnlAEvBe//BlSc3LD8/RxCSQ1Ca3w8bqHVQUuBLhXqbwDaHOZ5ihw2JRiRmrcLSIDQErXAz4C+7r7FzCaU7zuEinM8FQf/lvL//0//FFhPqGcVA+yuUD8hiEEkrHSJTOTofAQMCxZwSiO0VPFs4BPgkmAsphVwZoU2S4DOwfumQBGwLah37gE+J4b/n+X2SuDjQ8SVDKwNelBXE1qyulwXqnFmX5EDUQ9G5Oi8Rmh8ZT6hXsUv3H2dmb0CDAQWE1rJcy6wLWjzNqGE8093n29m84C8oN4nB/icIkILQ/2a0CWuYYeI6y/AK2Y2HJgatC93VhCDSFhpNmWRMDGzJHffYWYtCPVqTgmSTyNC626cEozdVOVYO9w9qZrimglc6O5bquN4IgeiHoxI+LwVLOzUAPhfd18H4O67zOxuQuudr6rJgILLeA8puUhNUA9GRETCQoP8IiISFkowIiISFkowIiISFkowIiISFkowIiISFv8HaPSEXchpWRIAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x116ce9e80>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is:  134.777\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([  1.47735802e+03,   4.91989104e+03,   1.15551430e+03,\n",
       "        -2.70917718e+01,  -4.82832150e+01,   4.32855700e+02,\n",
       "         1.25154448e+03,   0.00000000e+00,   5.14092931e+02,\n",
       "         1.30358187e+04,   1.90727648e+03,   3.50773615e+03,\n",
       "         0.00000000e+00,  -2.88686013e+03,  -1.48381718e+02,\n",
       "        -0.00000000e+00,   5.17794507e+03,   1.37481823e+02,\n",
       "         6.66244642e+03,   3.50672383e+02,  -0.00000000e+00,\n",
       "        -6.35129686e+02,  -0.00000000e+00,   9.61450194e+02,\n",
       "         4.84935342e+03,   0.00000000e+00,  -0.00000000e+00,\n",
       "         0.00000000e+00,  -0.00000000e+00,  -3.79144463e+02,\n",
       "         0.00000000e+00,   2.38865547e+03,  -3.90618957e+03,\n",
       "        -2.31951992e+03,   1.25341094e+03,   3.30864517e+03,\n",
       "         4.50515954e+03,   2.05562307e+03,   5.80084839e+02,\n",
       "        -0.00000000e+00,  -0.00000000e+00,  -0.00000000e+00,\n",
       "         2.50935274e+03,  -2.44480069e+02,  -1.80476854e+02,\n",
       "         1.82248991e+03,   1.70346099e+03,  -0.00000000e+00,\n",
       "         6.55936658e+02,   2.47484083e+03,  -0.00000000e+00,\n",
       "        -3.99778674e+03,  -1.57207339e+03,   6.81375788e+02,\n",
       "         7.43151131e+03,  -0.00000000e+00,   3.05812118e+03,\n",
       "         7.36223395e+01,   8.62303699e+02,   2.08515213e+03,\n",
       "         4.12945936e+03,  -0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   5.32721960e+02,  -1.81440196e+03,\n",
       "         5.29413327e+03,   0.00000000e+00,   2.08947365e+04,\n",
       "         0.00000000e+00,   0.00000000e+00,   6.01145686e+03,\n",
       "         4.44876208e+03,   0.00000000e+00,   1.75118062e+03,\n",
       "         2.02514113e+03,   0.00000000e+00,   0.00000000e+00,\n",
       "        -0.00000000e+00,   0.00000000e+00,   6.04556017e+03,\n",
       "        -2.96015486e+02,   0.00000000e+00,  -0.00000000e+00,\n",
       "        -8.09015358e+02,   0.00000000e+00,   1.91117062e+03,\n",
       "        -2.40469011e+03,   0.00000000e+00,   2.44362959e+03,\n",
       "        -0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,  -6.67789385e+03,\n",
       "         2.37807893e+03,   1.31731677e+04,   0.00000000e+00,\n",
       "        -0.00000000e+00,  -0.00000000e+00,  -0.00000000e+00,\n",
       "         0.00000000e+00,  -0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,  -0.00000000e+00,\n",
       "         6.00344188e+03,  -0.00000000e+00,  -0.00000000e+00,\n",
       "        -0.00000000e+00,  -0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "        -0.00000000e+00,  -0.00000000e+00,   0.00000000e+00,\n",
       "        -0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,  -0.00000000e+00,   0.00000000e+00,\n",
       "        -1.55433094e+03,   0.00000000e+00,  -0.00000000e+00,\n",
       "        -0.00000000e+00,  -0.00000000e+00,   7.76180658e+03,\n",
       "        -0.00000000e+00,   0.00000000e+00,  -9.86890171e+02,\n",
       "         0.00000000e+00,   3.05245954e+02,  -0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,  -1.18395548e+03,\n",
       "        -1.99029602e+03,   0.00000000e+00,   0.00000000e+00,\n",
       "        -0.00000000e+00,  -0.00000000e+00,   0.00000000e+00,\n",
       "        -0.00000000e+00,  -0.00000000e+00,   2.61749312e+03,\n",
       "        -1.92293319e+03,   0.00000000e+00,   0.00000000e+00,\n",
       "        -0.00000000e+00,  -2.20901136e+03,  -0.00000000e+00,\n",
       "        -0.00000000e+00,  -0.00000000e+00,   1.01116034e+03,\n",
       "         0.00000000e+00,   0.00000000e+00,  -0.00000000e+00,\n",
       "        -0.00000000e+00,   0.00000000e+00,  -0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "        -3.37860449e+03,   7.98642195e+02,   0.00000000e+00,\n",
       "        -0.00000000e+00,  -0.00000000e+00,   0.00000000e+00,\n",
       "         4.33333429e+02,  -0.00000000e+00,  -2.76345292e+03,\n",
       "         0.00000000e+00,   0.00000000e+00,  -0.00000000e+00,\n",
       "        -0.00000000e+00,  -0.00000000e+00,   1.82182172e+03,\n",
       "         0.00000000e+00,   0.00000000e+00,  -0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   2.74800321e+03,\n",
       "        -0.00000000e+00,  -0.00000000e+00,  -0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,  -0.00000000e+00,  -0.00000000e+00,\n",
       "        -0.00000000e+00,   1.56837457e+03,  -0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         5.04429859e+03,  -1.23250481e+03,  -0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   7.10937198e+03,\n",
       "        -0.00000000e+00,  -0.00000000e+00,  -0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "        -2.26336393e+03,  -0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,  -1.19311035e+03,   0.00000000e+00,\n",
       "         0.00000000e+00,   1.03967909e+03,   0.00000000e+00,\n",
       "         9.88536791e+02,  -0.00000000e+00,  -0.00000000e+00,\n",
       "        -0.00000000e+00,  -0.00000000e+00,   0.00000000e+00,\n",
       "        -1.35248036e+03,   7.27139300e+03,   0.00000000e+00,\n",
       "         3.42175682e+02,  -7.69565123e+02,   0.00000000e+00,\n",
       "        -0.00000000e+00,  -0.00000000e+00,   0.00000000e+00,\n",
       "         8.46383907e+03,   0.00000000e+00,  -0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "        -0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "        -0.00000000e+00,   0.00000000e+00,  -5.42760070e+02,\n",
       "         0.00000000e+00,   4.89694121e+02,  -0.00000000e+00,\n",
       "        -7.83146726e+02,   2.05419493e+03,  -0.00000000e+00,\n",
       "        -4.98470751e+02,   0.00000000e+00,   0.00000000e+00,\n",
       "        -0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         8.38784381e+03,  -0.00000000e+00,  -1.74255026e+03,\n",
       "         2.29241576e+04,  -0.00000000e+00,  -1.94710124e+03,\n",
       "        -0.00000000e+00,  -3.84854583e+03,  -4.74140415e+03,\n",
       "        -0.00000000e+00,   0.00000000e+00,  -2.20160666e+03,\n",
       "         0.00000000e+00,   2.86283953e+04,  -0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,  -0.00000000e+00,\n",
       "         6.23823590e+02,   3.12525952e+04,   0.00000000e+00,\n",
       "         2.87799454e+03,   0.00000000e+00,  -0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,  -0.00000000e+00,\n",
       "        -0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,  -0.00000000e+00,  -3.54223460e+03,\n",
       "         0.00000000e+00,   1.42599023e+03,  -0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,  -1.60767906e+02,\n",
       "         0.00000000e+00,  -0.00000000e+00,  -0.00000000e+00,\n",
       "         6.62027250e+03,   0.00000000e+00,   0.00000000e+00,\n",
       "        -0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "        -0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,  -0.00000000e+00,  -3.98666290e+03,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "         0.00000000e+00])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses)\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()\n",
    "\n",
    "print('alpha is: ', lasso.alpha_)\n",
    "lasso.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Lasso Regression on train is 0.920961505031\n",
      "Lasso Regression on test is 0.906782227777\n",
      "LassoCV_RMSE on train: 21724.6557057\n",
      "LassoCV_RMSE on test: 22657.769959\n"
     ]
    }
   ],
   "source": [
    "print('Lasso Regression on train is', lasso.score(X_train, y_train))\n",
    "print('Lasso Regression on test is', lasso.score(X_test, y_test))\n",
    "LassoCV_RMSE_train = np.sqrt(mean_squared_error(LassoCV_y_predict_train, y_train))\n",
    "LassoCV_RMSE_test = np.sqrt(mean_squared_error(LassoCV_y_predict_test, y_test))\n",
    "print('LassoCV_RMSE on train:', LassoCV_RMSE_train)\n",
    "print('LassoCV_RMSE on test:', LassoCV_RMSE_test)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[  1.03981685e+05   5.39895810e+08   1.84874648e+05 ...,   1.62448970e+05\n",
      "   1.22012905e+05   2.29527233e+05]\n"
     ]
    }
   ],
   "source": [
    "lr_final_predict = lr.predict(X2)\n",
    "# lr_y_predict_train = lr.predict(X_train)\n",
    "print(lr_final_predict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 111065.16828558  138335.88528125  190989.50062175 ...,  164542.98110152\n",
      "  123483.39007992  231084.88393362]\n"
     ]
    }
   ],
   "source": [
    "sgdr_final_predict = sgdr.predict(X2)\n",
    "print(sgdr_final_predict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 111890.5859221   122452.41266723  189079.61219127 ...,  167580.0528519\n",
      "  127016.33355687  233118.38671547]\n"
     ]
    }
   ],
   "source": [
    "reg_final_predict = reg.predict(X2)\n",
    "print(reg_final_predict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 116783.85696711  120059.30264608  189534.69145197 ...,  168268.39235407\n",
      "  126445.62376845  235392.16620312]\n"
     ]
    }
   ],
   "source": [
    "lasso_final_predict = lasso.predict(X2)\n",
    "print(lasso_final_predict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LinearREgression on train is  0.940369445012\n",
      "LinearRegression on test is  -307389115.61\n",
      "LR_RMSE on train: 18869.8304163\n",
      "LR_RMSE on test: 1301104103.99\n",
      "\n",
      "\n",
      "SGDRegressor on train is  0.934500774487\n",
      "SGDRegressor on test is  0.900640960572\n",
      "SGDR_RMSE on train: 19776.6011036\n",
      "SGDR_RMSE on test: 23392.2229983\n",
      "\n",
      "\n",
      "RidgeRegression on train is  0.926298160517\n",
      "RidgeRegression on test is 0.909415562833\n",
      "RidgeCV_RMSE on train: 20978.4180262\n",
      "RidgeCV_RMSE on test: 22335.4444283\n",
      "\n",
      "\n",
      "Lasso Regression on train is 0.920961505031\n",
      "Lasso Regression on test is 0.906782227777\n",
      "LassoCV_RMSE on train: 21724.6557057\n",
      "LassoCV_RMSE on test: 22657.769959\n"
     ]
    }
   ],
   "source": [
    "#all models:\n",
    "print('LinearREgression on train is ', lr.score(X_train, y_train))\n",
    "print('LinearRegression on test is ', lr.score(X_test, y_test))\n",
    "print('LR_RMSE on train:', lr_RMSE_train)\n",
    "print('LR_RMSE on test:', lr_RMSE_test)\n",
    "print('\\n')\n",
    "print('SGDRegressor on train is ', sgdr.score(X_train, y_train))\n",
    "print('SGDRegressor on test is ', sgdr.score(X_test, y_test))\n",
    "print('SGDR_RMSE on train:', SGDR_RMSE_train)\n",
    "print('SGDR_RMSE on test:', SGDR_RMSE_test)\n",
    "print('\\n')\n",
    "print('RidgeRegression on train is ', reg.score(X_train, y_train))\n",
    "print('RidgeRegression on test is', reg.score(X_test, y_test))\n",
    "print('RidgeCV_RMSE on train:', RidgeCV_RMSE_train)\n",
    "print('RidgeCV_RMSE on test:', RidgeCV_RMSE_test) \n",
    "print('\\n')\n",
    "print('Lasso Regression on train is', lasso.score(X_train, y_train))\n",
    "print('Lasso Regression on test is', lasso.score(X_test, y_test))\n",
    "print('LassoCV_RMSE on train:', LassoCV_RMSE_train)\n",
    "print('LassoCV_RMSE on test:', LassoCV_RMSE_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>333</th>\n",
       "      <th>334</th>\n",
       "      <th>335</th>\n",
       "      <th>336</th>\n",
       "      <th>337</th>\n",
       "      <th>338</th>\n",
       "      <th>339</th>\n",
       "      <th>340</th>\n",
       "      <th>341</th>\n",
       "      <th>342</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.670403</td>\n",
       "      <td>0.119019</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>0.700717</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>-0.694099</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>-0.337364</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.699931</td>\n",
       "      <td>0.387346</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>-1.028509</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>-0.694099</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>-0.436731</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.493235</td>\n",
       "      <td>0.343014</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>-1.028509</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>-0.694099</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>0.855035</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.611347</td>\n",
       "      <td>-0.047760</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>-1.028509</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>-0.694099</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>0.888158</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-0.422133</td>\n",
       "      <td>-0.552255</td>\n",
       "      <td>0.064327</td>\n",
       "      <td>-0.243378</td>\n",
       "      <td>-1.028509</td>\n",
       "      <td>0.026216</td>\n",
       "      <td>0.226042</td>\n",
       "      <td>1.253123</td>\n",
       "      <td>-0.419233</td>\n",
       "      <td>0.689424</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 343 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          0         1         2         3         4         5         6  \\\n",
       "0  0.670403  0.119019  0.064327 -0.243378  0.700717  0.026216  0.226042   \n",
       "1  0.699931  0.387346  0.064327 -0.243378 -1.028509  0.026216  0.226042   \n",
       "2  0.493235  0.343014  0.064327 -0.243378 -1.028509  0.026216  0.226042   \n",
       "3  0.611347 -0.047760  0.064327 -0.243378 -1.028509  0.026216  0.226042   \n",
       "4 -0.422133 -0.552255  0.064327 -0.243378 -1.028509  0.026216  0.226042   \n",
       "\n",
       "          7         8         9 ...   333  334  335  336  337  338  339  340  \\\n",
       "0 -0.694099 -0.419233 -0.337364 ...     1    1    1    1    1    1    1    1   \n",
       "1 -0.694099 -0.419233 -0.436731 ...     1    1    1    1    1    1    1    1   \n",
       "2 -0.694099 -0.419233  0.855035 ...     1    1    1    1    1    1    1    1   \n",
       "3 -0.694099 -0.419233  0.888158 ...     1    1    1    1    1    1    1    1   \n",
       "4  1.253123 -0.419233  0.689424 ...     1    1    1    1    1    1    1    1   \n",
       "\n",
       "   341  342  \n",
       "0    1    1  \n",
       "1    1    1  \n",
       "2    1    1  \n",
       "3    1    1  \n",
       "4    1    1  \n",
       "\n",
       "[5 rows x 343 columns]"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X2.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Best model is RidgeCV!\n"
     ]
    }
   ],
   "source": [
    "#conclution\n",
    "\n",
    "print('Best model is RidgeCV!')\n",
    "# predict_id2 = data2\n",
    "predict_df = pd.DataFrame({'id': predict_id, 'SalePrice': reg_final_predict})\n",
    "predict_df.to_csv('./Ames_House/AmesHouse_predict.csv', columns=['id', 'SalePrice'], index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
